<?php
/**
 * Buildings Model for Room Booking Component
 * 
 * @version 1.0
 * @package    Joomla
 * @subpackage RoomBooking
 * @copyright (C) 2011 Giovanni Marzulli
 * @license		GNU/GPL
 */
 
// No direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
 
jimport( 'joomla.application.component.model' );
 
class RoomBookingModelBuildings extends JModel
{
        
 	/**
    * Gets the buildings of Organization
    * @return array Array of objects containing the data from the database
    */
    function getBuildings($id_organization)
    {
		$db =& JFactory::getDBO();
 
  		$query = 'SELECT id, name, address, date_format( opening, "%H:%i" ) as opening, date_format( closing, "%H:%i" ) as closing, we_opening'.
  				 ' FROM #__roombooking_buildings AS r INNER JOIN '.
  				 ' #__roombooking_building_organization  AS ro ON r.id=ro.id_building WHERE id_organization='.$id_organization;
   		$buildings = $this->_getList( $query );
   		
   		return $buildings;
    	
    }
    
}
